//添加单个商品到购物车
function addCart(id,qty) {
	var arr = {
		hf_s_id: "WD11",
		hf_srv_id: "Av_jcart",
		hs_action_id: "add_all_to_cart",
		hvs_add_pdt_id:id,
		hvs_add_qty: qty
	};
	getAjaxRequest(arr, function (result) {
		if (result.bs_result == BS_RESULT.OK) {
			if (result.bs_is_login == BS_IS_LOGIN.Y) {
				dialog('Message', 'Add shopping cart success!', 1);
				var $dialog = $('#dialog');
				$dialog.show();
				$dialog.find('.comfirmBtn').one('click', function() {
					$dialog.hide();
					$dialog.remove();
				})
			} else {
				location.href = MPJ.base + "/pages/login.jsp?";
			}
		}

	});
}
//添加整个购物清单内的商品到购物车
function addCarts() {
	var lastUrl = '?hf_s_id=WD11&hf_srv_id=Av_jcart&hs_action_id=add_all_to_cart';
	for(var i = 0; i<productIds.length; i++){
		lastUrl += '&hvs_add_pdt_id='+productIds[i]+'&hvs_add_qty='+productQtys[i];
	}
	var url = MPJ.apiUrl + lastUrl;
	getAjaxRequest({}, function (result) {

		if (result.bs_result == BS_RESULT.OK) {
			if (result.bs_is_login == BS_IS_LOGIN.Y) {
				dialog('Message', 'Add shopping cart success!', 1);
				var $dialog = $('#dialog');
				$dialog.show();
				$dialog.find('.comfirmBtn').one('click', function() {
					$dialog.hide();
					$dialog.remove();
					getCartSumCount();
				})
			} else {
				location.href = MPJ.base + "/pages/login.jsp";
			}
		}

	},url);
}
//添加购物清单内的所有商品到购物车
$('.addCarts').on('tap',function(){
	addCarts();
})
function add() {
	$('.item').each(function () {
		var $this = $(this).find('.orderToCart');
		var id = $this.data('id');
		var qty = $this.data('qty');
		$this.on('tap', function () {
			addCart(id, qty);
		})
	})
}